/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.heyma.core.service;

import com.icg.entityclassutils.Attribute;
import com.icg.entityclassutils.Entity;
import com.icg.entityclassutils.EntityResult;
import com.icg.entityclassutils.SimpleFilter;
import com.icg.entityclassutils.Grouper;
import com.icg.entityclassutils.SimpleObject;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.heyma.packageutils.extja.treeloader.Element;
import org.heyma.packageutils.extja.treeloader.Folder;

/**
 *
 * @author John
 */
public interface IEntityServices {

    List<Folder> getEntities(String pkg) throws ClassNotFoundException, IOException;
    //fue cambiado por 
    //  *** public List<Element> EntitiesToExtTreeElements();
    //public List<Element> getEntities();

    void executeSQLStatement(String sql);

    //Object getEntityByID(String id) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException;
    //public boolean existAttribute(List<Attribute> attrs, Attribute input);
    public List<Attribute> getAttributesFromEntity(Object entity) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException;

    public void updateEntityStruct(Object entity);

    public void alterAddColumn(Entity entity, Attribute input) throws ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException;

    public boolean existTable(String schema, String tablename);
    
    public boolean existColumn(String schema, String tablename, String columnname);

    public void createTable(Entity entity) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException;

    public void alterDropColumn(Attribute attr);

    public Entity getFinalEntityByID(String id) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException;

    public List arrayEntityData(String id) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException;

    public List<SimpleObject> getSimpleObjectEntityData(Entity entity);

    public List jsonEntityData(String id) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException;
    
    public List<Element> EntitiesToExtTreeElements();

    public void deleteObject(Entity entity, Long id);

    public void alterUpdateColumn(Attribute input);

    public <T> List<T> getListFromStructProperty(Object entity, Class<T> type, String lstProperty) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException;

    public void setListToStructProperty(Object entity, List<? extends Object> objects, String lstProperty) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException;

    public <T> T jsonToObject(String JSON, Class<T> type);

    public List<Attribute> getAttributesOfGroup(List<Attribute> attrs, Grouper group);

    public List<Map<String, Object>> jsonData(Entity entity, Long parent_id);
    
    public List<Map<String, Object>> jsonData(Entity entity, SimpleFilter filter);

    public List<Map<String, Object>> getAllObjectsOfEntity(Entity entity);

    public List<Map<String, Object>> schemaTables(String schema);

    public List<Map<String, Object>> tableColumns(String schema, String tableName);

    public List<Map<String, Object>> tableColumns(List<Map<String, Object>> schemaColumns, String tableName);

    public List<Map<String, Object>> schemaColumns(String schema);

    public Map<String, String> tableColumnsMap(String schema, String tableName);
    
    public Map<String, String> tableColumnsMap(List<Map<String, Object>> columns);    

    public List<Map<String, Object>> noEntityDataBase();
    
    public EntityResult get(String entity, Object id);
    
    public EntityResult get(String entity, Object id, String[] fields);
    
    public EntityResult get(String schema, String entity, Object id);
    
    public EntityResult get(String schema, String entity, Object id, String[] fields);
    
    public EntityResult find(String entity);
    
    public EntityResult find(String schema, String entity);
    
    public EntityResult find(String schema, String entity, String[] orderFields);
    
    public EntityResult find(String entity, SimpleFilter filter);
    
    public EntityResult find(String schema, String entity, SimpleFilter filter);
    
    public EntityResult find(String entity, SimpleFilter filter, String[] fields);
    
    public EntityResult find(String schema, String entity, SimpleFilter filter, String[] fields);
    
    public EntityResult persist(Map<String, Object> insertable, String entity);
    
    public EntityResult persist(Map<String, Object> insertable, String schema, String entity);
    
    public EntityResult persist(Map<String, Object> insertable, String schema, String entity, Object id);

    public List<Map<String, Object>> getAddOnEntitiess();
    
    public boolean existObject(String schema, String entity, String field, Object value);
    
    public Map<String, Object> getExistObject(String schema, String entity, String field, Object value);
    
    public Map<String, Object> getExistObject(String schema, String entity, String field, Object value, String[] fields);
    
    public Map<String, Object> buildPersistenObjectFromRequest(String schema, String entity, HttpServletRequest request) throws ParseException;

    public void persistRam(Map<String, Object> insertable, String id);

    public Map<String, Object> dataRam(String id);

    public Map<String, Object> getRam(String entity, Long id);

    public void deleteObjectRam(String entity, Long id);
    
    public Set<String> tableMapToPostgisColumns(Set<Entry<String, String>> entries);
    
    public void clearCache();
    
    public void deleteObject(String schema, String entity, Object id);
}
